﻿package mortal.game.view.interfaceCallModule
{
    import __AS3__.vec.*;
    import baseEngine.core.*;
    import baseEngine.system.*;
    import com.gengine.keyBoard.*;
    import com.mui.containers.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import fl.controls.*;
    import flash.events.*;
    import flash.utils.*;
    import mortal.game.manager.*;
    import mortal.game.manager.window3d.*;
    import mortal.game.resource.*;
    import mortal.game.scene3D.player.entity.*;
    import mortal.game.view.common.*;

    public class UITrackPanelSub1 extends GSprite
    {
        protected var _bg1:ScaleBitmap;
        protected var ui_1:GTextFiled;
        protected var ui_2:GTextFiled;
        protected var _bg2:ScaleBitmap;
        protected var _btn1:GButton;
        protected var ui_5:GTextFiled;
        protected var _bg3:ScaleBitmap;
        protected var _btn2:GButton;
        protected var _bg4:ScaleBitmap;
        protected var ui_10:GTextFiled;
        protected var _allBtn:GButton;
        protected var _3dNameIn:GTextInput;
        protected var _3dName:GTextFiled;
        protected var _3dF:GTextFiled;
        protected var _3dSeleBtn:GButton;
        protected var _3dX:GTextFiled;
        protected var _3dY:GTextFiled;
        protected var _3dXIn:GTextInput;
        protected var _3dYIn:GTextInput;
        protected var _3dXAdd:GLoadedButton;
        protected var _3dXSub:GLoadedButton;
        protected var _3dYAdd:GLoadedButton;
        protected var _3dYSub:GLoadedButton;
        protected var _3dOKBtn:GButton;
        protected var _3dScalXT:GTextFiled;
        protected var _3dScalYT:GTextFiled;
        protected var _scalXIn:GTextInput;
        protected var _scalYIn:GTextInput;
        protected var _3dOtherTxt:GTextInput;
        protected var _3dOther:GTextFiled;
        private var _proArea1:TextArea;
        private var _proArea2:TextArea;
        private var _proArea3:TextArea;
        private var _proArea4:TextArea;
        private var _3dSelP:Pivot3D;
        private var _objInfo:Obj3dInfo;
        private var _rect3d:Rect3DObject;
        public static var window:IWindow3D;

        public function UITrackPanelSub1()
        {
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            var _loc_1:Array = [];
            _loc_1.push({name:"GTextFiled", label:"GTextFiled"});
            _loc_1.push({name:"GButton", label:"GButton"});
            this._bg1 = UIFactory.bg(28, 99, 424, 63, this, ImagesConst.PanelBg);
            this.ui_1 = UIFactory.gTextField("条件：", 30, 78, 100, 20, this);
            this.ui_2 = UIFactory.gTextField("结果：", 30, 165, 100, 20, this);
            this._bg2 = UIFactory.bg(28, 193, 424, 73, this, ImagesConst.PanelBg);
            this._btn1 = UIFactory.gButton("查询", 436, 164, 50, 25, this);
            this.ui_5 = UIFactory.gTextField("从池中查询", 30, 271, 100, 20, this);
            this._bg3 = UIFactory.bg(28, 293, 408, 73, this, ImagesConst.PanelBg);
            this._btn2 = UIFactory.gButton("查询", 437, 294, 50, 25, this);
            this._bg4 = UIFactory.bg(29, 386, 454, 103, this, ImagesConst.PanelBg);
            this.ui_10 = UIFactory.gTextField("结果：", 30, 366, 100, 20, this);
            this._allBtn = UIFactory.gButton("全部", 438, 353, 50, 28, this);
            this._3dNameIn = UIFactory.gTextInput(62, 517, 114, 20, this);
            this._3dName = UIFactory.gTextField("名字：", 15, 515, 50, 20, this);
            this._3dF = UIFactory.gTextField("3d", 15, 492, 100, 20, this);
            this._3dSeleBtn = UIFactory.gButton("选中", 210, 511, 50, 30, this);
            this._3dX = UIFactory.gTextField("x:", 15, 543, 100, 20, this);
            this._3dY = UIFactory.gTextField("y:", 15, 563, 100, 20, this);
            this._3dXIn = UIFactory.gTextInput(36, 545, 30, 20, this);
            this._3dYIn = UIFactory.gTextInput(36, 570, 30, 20, this);
            this._3dXAdd = UIFactory.gLoadedButton(ImagesConst.sup3_upSkin, 99, 546, 16, 16, this);
            this._3dXAdd.label = "";
            this._3dXSub = UIFactory.gLoadedButton(ImagesConst.sub3_upSkin, 78, 546, 16, 16, this);
            this._3dXSub.label = "";
            this._3dYAdd = UIFactory.gLoadedButton(ImagesConst.sup3_upSkin, 100, 571, 16, 16, this);
            this._3dYAdd.label = "";
            this._3dYSub = UIFactory.gLoadedButton(ImagesConst.sub3_upSkin, 78, 571, 16, 16, this);
            this._3dYSub.label = "";
            this._3dOKBtn = UIFactory.gButton("确定", 512, 548, 50, 30, this);
            this._3dScalXT = UIFactory.gTextField("scalX:", 147, 544, 50, 20, this);
            this._3dScalYT = UIFactory.gTextField("scalY:", 148, 568, 50, 20, this);
            this._scalXIn = UIFactory.gTextInput(192, 544, 30, 20, this);
            this._scalYIn = UIFactory.gTextInput(193, 572, 30, 20, this);
            this._3dOtherTxt = UIFactory.gTextInput(247, 570, 220, 20, this);
            this._3dOther = UIFactory.gTextField("其他参数：", 245, 544, 100, 20, this);
            this._scalYIn.setStyle("upSkin", "");
            this._scalYIn.setStyle("disabledSkin", "");
            this._scalYIn.drawNow();
            this._proArea1 = UIFactory.textArea("", this._bg1.x, this._bg1.y, 100, 100, this);
            this._proArea1.width = this._bg1.width;
            this._proArea1.height = this._bg1.height;
            this._proArea1.editable = true;
            this._proArea2 = UIFactory.textArea("", this._bg2.x, this._bg2.y, 100, 100, this);
            this._proArea2.width = this._bg2.width;
            this._proArea2.height = this._bg2.height;
            this._proArea2.editable = true;
            this._proArea3 = UIFactory.textArea("", this._bg3.x, this._bg3.y, 100, 100, this);
            this._proArea3.width = this._bg3.width;
            this._proArea3.height = this._bg3.height;
            this._proArea3.editable = true;
            this._proArea4 = UIFactory.textArea("", this._bg4.x, this._bg4.y, 100, 100, this);
            this._proArea4.width = this._bg4.width;
            this._proArea4.height = this._bg4.height;
            this._proArea4.editable = true;
            this._btn1.configEventListener(MouseEvent.CLICK, this.onFind1);
            this._btn2.configEventListener(MouseEvent.CLICK, this.onFind2);
            this._allBtn.configEventListener(MouseEvent.CLICK, this.allPrint);
            this._3dSeleBtn.configEventListener(MouseEvent.CLICK, this.select3D);
            this._3dOKBtn.configEventListener(MouseEvent.CLICK, this.onOKCk);
            this._3dXAdd.configEventListener(MouseEvent.MOUSE_DOWN, this.adjustCk);
            this._3dXSub.configEventListener(MouseEvent.MOUSE_DOWN, this.adjustCk);
            this._3dYAdd.configEventListener(MouseEvent.MOUSE_DOWN, this.adjustCk);
            this._3dYSub.configEventListener(MouseEvent.MOUSE_DOWN, this.adjustCk);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            this._bg1 = null;
            this.ui_1 = null;
            this.ui_2 = null;
            this._bg2 = null;
            this._btn1 = null;
            this.ui_5 = null;
            this._bg3 = null;
            this._btn2 = null;
            this._bg4 = null;
            this.ui_10 = null;
            this._allBtn = null;
            this._3dNameIn = null;
            this._3dName = null;
            this._3dF = null;
            this._3dSeleBtn = null;
            this._3dX = null;
            this._3dY = null;
            this._3dXIn = null;
            this._3dYIn = null;
            this._3dXAdd = null;
            this._3dXSub = null;
            this._3dYAdd = null;
            this._3dYSub = null;
            this._3dOKBtn = null;
            this._3dScalXT = null;
            this._3dScalYT = null;
            this._scalXIn = null;
            this._scalYIn = null;
            this._3dOtherTxt = null;
            this._3dOther = null;
            this.removeChild(this._proArea1);
            this.removeChild(this._proArea2);
            this.removeChild(this._proArea3);
            this.removeChild(this._proArea4);
            this._proArea1 = null;
            this._proArea2 = null;
            this._proArea3 = null;
            this._proArea4 = null;
            super.disposeImpl(param1);
            return;
        }// end function

        private function onFind1(event:MouseEvent) : void
        {
            var _loc_8:Object = null;
            var _loc_9:String = null;
            var _loc_10:Array = null;
            var _loc_11:GTextFiled = null;
            var _loc_12:int = 0;
            var _loc_13:String = null;
            var _loc_14:String = null;
            var _loc_2:* = this._proArea1.text;
            var _loc_3:* = _loc_2.split(",");
            var _loc_4:Array = [];
            var _loc_5:int = 0;
            while (_loc_5 < _loc_3.length)
            {
                
                _loc_4[_loc_5] = [];
                _loc_9 = _loc_3[_loc_5];
                _loc_10 = _loc_9.split("=");
                _loc_4[_loc_5][0] = "" + _loc_10[0];
                _loc_4[_loc_5][1] = "" + _loc_10[1];
                _loc_5++;
            }
            var _loc_6:* = UIComTrackUtil.instanceObj;
            var _loc_7:String = "";
            for (_loc_8 in _loc_6)
            {
                
                _loc_11 = _loc_8 as GTextFiled;
                if (_loc_11)
                {
                    _loc_12 = 0;
                    while (_loc_12 < _loc_4.length)
                    {
                        
                        if (_loc_11.hasOwnProperty(_loc_4[_loc_12][0]))
                        {
                            if (_loc_4[_loc_12][0] == "text")
                            {
                                _loc_13 = _loc_11[_loc_4[_loc_12][0]];
                                _loc_14 = _loc_4[_loc_12][1];
                                if (_loc_13.indexOf(_loc_14) != -1)
                                {
                                    _loc_7 = _loc_7 + (_loc_11.name + ",\n");
                                }
                            }
                            else if (_loc_11[_loc_4[_loc_12][0]] + "" == _loc_4[_loc_12][1])
                            {
                                _loc_7 = _loc_7 + (_loc_11.name + ",\n");
                            }
                        }
                        _loc_12++;
                    }
                }
            }
            this._proArea2.text = "" + _loc_7;
            return;
        }// end function

        private function onFind2(event:MouseEvent) : void
        {
            var _loc_5:Object = null;
            var _loc_6:GTextFiled = null;
            var _loc_2:* = this._proArea3.text;
            var _loc_3:* = UIComTrackUtil.instanceObj;
            var _loc_4:String = "";
            for (_loc_5 in _loc_3)
            {
                
                _loc_6 = _loc_5 as GTextFiled;
                if (_loc_6.name == _loc_2)
                {
                    _loc_4 = _loc_6["parentArr"].toString(",");
                }
            }
            this._proArea4.text = "" + _loc_4;
            return;
        }// end function

        private function allPrint(event:MouseEvent) : void
        {
            this._proArea4.text = "" + UIComTrackUtil.toStr("GTextFiled");
            return;
        }// end function

        private function select3D(event:MouseEvent) : void
        {
            if (window == null)
            {
                MsgManager.showRollTipsMsg("window 空");
                return;
            }
            this._rect3d = Rect3DManager.instance.getRect3dByWindow(window);
            if (this._rect3d == null)
            {
                MsgManager.showRollTipsMsg("rect3d 空");
                return;
            }
            var _loc_2:* = this._rect3d.obj3dList;
            this._objInfo = null;
            var _loc_3:* = "" + this._3dNameIn.text;
            var _loc_4:int = 0;
            while (_loc_4 < _loc_2.length)
            {
                
                this._objInfo = _loc_2[_loc_4];
                if (this._objInfo.obj3d.name == _loc_3)
                {
                    break;
                }
                this._objInfo = null;
                _loc_4++;
            }
            if (!this._objInfo)
            {
                MsgManager.showRollTipsMsg("没找到物体");
                return;
            }
            this._3dXIn.text = "" + this._objInfo.modlelocalPos.x;
            this._3dYIn.text = "" + this._objInfo.modlelocalPos.y;
            this._scalXIn.text = "" + this._objInfo.obj3d.scaleX;
            this._scalYIn.text = "" + this._objInfo.obj3d.scaleY;
            return;
        }// end function

        private function onOKCk(event:MouseEvent) : void
        {
            if (this._objInfo == null)
            {
                MsgManager.showRollTipsMsg("请选择物体");
                return;
            }
            this._objInfo.modlelocalPos.x = int(this._3dXIn.text);
            this._objInfo.modlelocalPos.y = int(this._3dYIn.text);
            this._objInfo.obj3d.scaleX = Number(this._scalXIn.text);
            this._objInfo.obj3d.scaleY = Number(this._scalYIn.text);
            if (this._objInfo.obj3d.scaleX == 0)
            {
                this._objInfo.obj3d.scaleX = 1;
            }
            if (this._objInfo.obj3d.scaleY == 0)
            {
                this._objInfo.obj3d.scaleY = 1;
            }
            this._rect3d.moveObj3d(this._objInfo, Global3D.scene.viewPort);
            this.otherParam();
            return;
        }// end function

        private function otherParam() : void
        {
            this.userModulePlayer();
            return;
        }// end function

        private function userModulePlayer() : void
        {
            var _loc_1:* = this._objInfo.obj3d as UserModelPlayer;
            var _loc_2:* = this._3dOtherTxt.text;
            if (_loc_1 == null || _loc_2 == "")
            {
                return;
            }
            var _loc_3:int = 1;
            var _loc_4:int = 0;
            var _loc_5:int = 0;
            var _loc_6:int = 110000;
            var _loc_7:int = 0;
            var _loc_8:int = 0;
            _loc_3 = int(this.getParaValue("career", _loc_2));
            _loc_4 = int(this.getParaValue("sex", _loc_2));
            _loc_5 = int(this.getParaValue("clothes", _loc_2));
            _loc_1.updateInfo(_loc_3, _loc_4, _loc_5, _loc_6, _loc_7, _loc_8);
            return;
        }// end function

        private function getParaValue(param1:String, param2:String) : String
        {
            var _loc_5:String = null;
            var _loc_3:* = param2.split(",");
            param1 = param1 + ":";
            var _loc_4:int = 0;
            while (_loc_4 < _loc_3.length)
            {
                
                _loc_5 = _loc_3[_loc_4];
                if (_loc_5.indexOf(param1) != -1)
                {
                    return _loc_5.slice(param1.length);
                }
                _loc_4++;
            }
            return "";
        }// end function

        private function adjustCk(event:MouseEvent) : void
        {
            var _loc_2:* = event.target as GLoadedButton;
            var _loc_3:int = 1;
            if (KeyBoardManager.ctrlKey)
            {
                _loc_3 = 10;
            }
            switch(_loc_2)
            {
                case this._3dXSub:
                {
                    this._objInfo.modlelocalPos.x = this._objInfo.modlelocalPos.x - _loc_3;
                    break;
                }
                case this._3dXAdd:
                {
                    this._objInfo.modlelocalPos.x = this._objInfo.modlelocalPos.x + _loc_3;
                    break;
                }
                case this._3dYSub:
                {
                    this._objInfo.modlelocalPos.y = this._objInfo.modlelocalPos.y - _loc_3;
                    break;
                }
                case this._3dYAdd:
                {
                    this._objInfo.modlelocalPos.y = this._objInfo.modlelocalPos.y + _loc_3;
                    break;
                }
                default:
                {
                    break;
                }
            }
            this._3dXIn.text = "" + this._objInfo.modlelocalPos.x;
            this._3dYIn.text = "" + this._objInfo.modlelocalPos.y;
            this._rect3d.moveObj3d(this._objInfo, Global3D.scene.viewPort);
            return;
        }// end function

    }
}
